import time
import unittest
from scropts.test01_login import TestLogin
from scropts.test03_employee import TestEmployee
from tools.HTMLTestRunner import HTMLTestRunner

# 封装测试套件
suite = unittest.TestSuite()
# 登录接口测试用例
suite.addTest(unittest.makeSuite(TestLogin))

# 员工管理场景测试用例
suite.addTest(TestLogin("test01_login_success"))
suite.addTest(unittest.makeSuite(TestEmployee))

# 指定测试报告路径
report = "./report/report-{}.html".format(time.strftime("%Y%m%d - %H%M%S"))

# 文件流形式打开文件
with open(report,"wb") as f:
    # 创建HTMLTestRunner的运行器（参数1-》指定写入的文件）
    runner = HTMLTestRunner(f, title="接口测试文档")
    # 执行测试套件
    runner.run(suite)
